package com.blog.service;

import com.blog.mapper.GoodMapper;
import com.blog.seckill.goods.Good;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @ClassName GoodBaseService
 * @Destription  Good基础：增删改查
 * @Author 天堂小野花
 * @Date 2025/8/19  18:35
 * @Version 1.0
 */
@Service
public class GoodBaseService {
    @Autowired
    GoodMapper goodMapper;
    //表 Good
    public Good selectGoodById(Integer id){
        return goodMapper.selectByPrimaryKey(id);
    }
    public int insertGood(Good good){
        return goodMapper.insert(good);
    }
    public int updateGood(Good good){
        return goodMapper.updateByPrimaryKeySelective(good);
    }
    public int deleteGoodById(Integer id){
        return goodMapper.deleteByPrimaryKey(id);
    }

    public List<Good> selectAllGoods() {
        return goodMapper.selectAllGoods();
    }
    @Transactional
    public int goodInventoryNumById(Integer goodId, Integer num) {
        return goodMapper.goodInventoryNumById(goodId,num);
    }
}
